/**
  ******************************************************************************
  * @file    image.h
  * @author  Amaseing team
  * @version V1.0.0
  * @date    21-november-2013
  * @brief   Cam
  *         
  ******************************************************************************  
  */ 
#ifndef _IMAGE_H_
#define _IMAGE_H_

/* Public includes -----------------------------------------------------------*/
/* Public defines ------------------------------------------------------------*/
#define IMG_WIDTH 	(160)	
#define IMG_HEIGHT 	(160)		
#define IMG_MEMORY  (IMG_HEIGHT*(IMG_WIDTH/2))

/**
 * Image format: 	YUV 4:2:2 (analog) = YCbCr 4:2:2 (digital)
 * [4-bytes      ]
 * [Cb0|Y0|Cr0|Y1] - [Cb2|Y2|Cr2|Y3]
 *
 * Cb = 8-bit blue component in x-direction,  origin 0; value = 0x7F
 * Cr = 8-bit red component in y-direction,   origin 0; value = 0x7F
 * Yn = 8-bit value component in z-direction, origin 0; value = 0x00 (black/dark)
 */
typedef struct yuv{
	uint8_t 	Cb0; 
	uint8_t		Y0; 
	uint8_t 	Cr0;
	uint8_t 	Y1;
} yuv32_t;

// Make sure the size of this struct is a power of 32 (DMA), 32bits aligned
typedef struct
{
	//image meta data
	uint16_t width;
	uint16_t height;
	uint32_t pixels;
	uint16_t lut;
	uint16_t check; //Check of captured data is correct

	//image data
	yuv32_t data[IMG_MEMORY]; //32bits = 2 yuv pixels!

	uint32_t reserved[IMG_WIDTH];
} image_t;

/* Public functions ----------------------------------------------------------*/

#endif
